package com.mstore.action;

import java.util.List;

import com.mstore.pojo.SMSLog;
import com.mstore.service.SMSLogService;

public class SmsLogAction extends BaseAction {
	
	private static final long serialVersionUID = 8626886186504265378L;
	
	/**
	 * 查看短信记录
	 */
	private int index;
	private int page;
	private int totalSize;
	private List<SMSLog> smsList;
	private SMSLog smsLog;
	private SMSLogService smsLogService;

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getTotalSize() {
		return totalSize;
	}

	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
	}

	public List<SMSLog> getSmsList() {
		return smsList;
	}

	public void setSmsList(List<SMSLog> smsList) {
		this.smsList = smsList;
	}

	public SMSLog getSmsLog() {
		return smsLog;
	}

	public void setSmsLog(SMSLog smsLog) {
		this.smsLog = smsLog;
	}

	public SMSLogService getSmsLogService() {
		return smsLogService;
	}

	public void setSmsLogService(SMSLogService smsLogService) {
		this.smsLogService = smsLogService;
	}

	// 分页查询短信条数
	public String getList() {

		smsLog = new SMSLog();
		// 得到短信总条数
		totalSize = smsLogService.getCount();

		if (totalSize == 0) {
			totalSize = 1;
		}

		if (totalSize % 14 == 0) {
			page = totalSize / 14;
		} else {
			page = totalSize / 14 + 1;
		}

		// 判断如果小于等于0了 就让等于第一页
		if (index <= 0) {
			index = 1;
		}
		// 判断如果大于于等于Count总页数了 就让等于第Count
		if (index >= page) {
			index = page;
		}

		// 分页查询所有短信数据
		smsList = smsLogService.getList(smsLog, index);

		return SUCCESS;
	}
}
